<template>
    <h1>{{ msg }}</h1>

    <p>
        Recommended IDE setup:
        <a href="https://code.visualstudio.com/" target="_blank">VSCode</a>
        +
        <a href="https://marketplace.visualstudio.com/items?itemName=octref.vetur" target="_blank">
            Vetur
        </a>
        or
        <a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
        (if using
        <code>&lt;script setup&gt;</code>)
    </p>

    <p>See <code>README.md</code> for more information.</p>

    <p>
        <a href="https://vitejs.dev/guide/features.html" target="_blank">
            Vite Docs
        </a>
        |
        <a href="https://v3.vuejs.org/" target="_blank">Vue 3 Docs</a>
    </p>

    <button @click="count++">count is: {{ count }}</button>
    <button @click="add">count x 2</button>
    <p>
        Edit
        <code>components/HelloWorld.vue</code> to test hot module replacement.
    </p>

    <div class="form">
        <input type="text" v-model="studentState.student.id">
        <input type="text" v-model="studentState.student.name">
        <input type="text" v-model="studentState.student.age">
        <input type="submit" @click="addStudent">
    </div>

    <div class="box" v-for="item in studentsState.students" :key="item.id">{{item.name}} - {{item.age}}</div>
</template>

<script lang="ts">
    import { ref, defineComponent, reactive } from 'vue'
    import useStudents from '../coms/student'

    export default defineComponent({
        name: 'home',
        props: {
            msg: {
                type: String,
                required: true
            }
        },
        setup: () => {
            const count = ref(0);
            function add(){
                count.value *= 2;
            }
            let { studentState, studentsState, addStudent } = useStudents();
            return { count, add, studentState, studentsState, addStudent }
        }
    })

</script>

<style lang="less" scoped>
    @import './index.less';
</style>